package com.sob.lupus;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;

import com.sob.lupus.entidades.Jugador;


public class pLupus extends BasicGame{

	Camara camara;
	Jugador jugador;
	Arena arena;
	
	public pLupus() {
		super("Project Lupus");
	}

	public void init(GameContainer gameContainer) throws SlickException {
		gameContainer.setTargetFrameRate(60);
		camara=new Camara();
		arena=new Arena(500,250,"/res/texturasTerreno2.png", ""); //new Arena(5000,250,"/res/tiles2.png", "");
		jugador=new Jugador();
		jugador.y=(arena.sueloIni-4)*arena.TILE_SIZE;
	}

	public void render(GameContainer gameContainer, Graphics graphics) throws SlickException {
		arena.render(camara.xOff, camara.yOff);
		jugador.draw(camara.xOff, camara.yOff);
	}

	public void update(GameContainer gameContainer, int deltaTime) throws SlickException {
		Input input=gameContainer.getInput();
		//input.enableKeyRepeat();
		//System.out.println(input.isKeyRepeatEnabled());
		if(input.isKeyDown(Input.KEY_ESCAPE)){
			gameContainer.exit();
		}
		jugador.tick(arena, camara, deltaTime, input);
	}

    public static void main(String[] args) 
	throws SlickException
	{
	 AppGameContainer app = 
		new AppGameContainer(new pLupus());
	
	 app.setDisplayMode(1024, 768, false);
	 app.start();
	}
}
